package com.chaofan.order.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.nio.file.Path;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        Path imgPath = Path.of(System.getProperty("user.home"), ".OrderFood", "img");
        registry.addResourceHandler("/upload/**")
                .addResourceLocations("file:" + imgPath.toAbsolutePath());
    }
}